home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / GRAPHICS.SWG / 0114_MODE-X Routines.pas < prev    next >
Pascal/Delphi Source File  |  1994-08-24  |  2KB  |  97 lines

  1. {
  2.  JW> What is mode-x or ($13) or whatever in graphics.  I like to write
  3.      Mode-x is just your 320x200x256 VGA graphics mode.
  4.  
  5. It's pretty similar to using pascal's graph unit, except you don't!  You have
  6. to get all the procedures and functions set-up yourself.
  7. }
  8.  
  9. PROCEDURE InitVGA; ASSEMBLER;  {Puts you in 320x200x256 VGA}
  10. asm 
  11.    mov  ax, 13h 
  12.    int  10h 
  13. end; 
  14.  
  15. PROCEDURE InitTEXT; ASSEMBLER; {Puts you back in 80x25 text mode} 
  16. asm 
  17.    mov  ax, 03h 
  18.    int  10h 
  19. end; 
  20.  
  21. PROCEDURE SetColor (ColorNo, Red, Green, Blue : byte); 
  22. begin     {Changes the pallete data for a particular colour} 
  23.      PORT[$3C8] := ColorNo; 
  24.      PORT[$3C9] := Red; 
  25.      PORT[$3C9] := Green; 
  26.      PORT[$3C9] := Blue; 
  27. end; 
  28.  
  29. PROCEDURE MovCursor (X,Y : byte);  {Moves the cursor to (X,Y)} 
  30. begin 
  31.   asm 
  32.   MOV   ah, 02h 
  33.   XOR   bx, bx 
  34.   MOV   dh, Y 
  35.   MOV   dl, X 
  36.   INT   10h 
  37.   end; 
  38. end; 
  39.  
  40. FUNCTION ReadCursorX: byte; assembler;  {Get X position of cursor}
  41. asm 
  42.   MOV   ah, 03h 
  43.   XOR   bx, bx 
  44.   INT   10h 
  45.   MOV   al, dl 
  46. end; 
  47.  
  48. FUNCTION ReadCursorY: byte; assembler;  {Get Y position of cursor} 
  49. asm 
  50.   MOV   ah, 03h 
  51.   XOR   bx, bx 
  52.   INT   10h 
  53.   MOV   al, dh 
  54. end; 
  55.  
  56. PROCEDURE PutText (TextData : string; Color : byte);  {Write a string} 
  57. var      {It's not the fastest way to do it, but it does the job} 
  58.  z, ASCdata, CursorX, CursorY : byte; 
  59. begin 
  60.  CursorX := ReadCursorX;
  61.  CursorY := ReadCursorY; 
  62.  for z := 1 to Length(TextData) do 
  63.  begin 
  64.   ASCdata := Ord(TextData[z]); 
  65.   asm 
  66.   MOV   ah, 0Ah 
  67.   MOV   al, ASCdata 
  68.   XOR   bx, bx 
  69.   MOV   bl, Color 
  70.   MOV   cx, 1 
  71.   INT   10h 
  72.   end; 
  73.   inc(CursorX); 
  74.   if CursorX=40 then begin CursorX:=0; inc(CursorY); end; 
  75.   MovCursor(CursorX,CursorY); 
  76.  end; 
  77. end; 
  78.  
  79. PROCEDURE PlotPixel(X, Y: Word; Color: Byte); ASSEMBLER; {Plots a pixel} 
  80. asm
  81.    push es 
  82.    push di 
  83.    mov  ax, Y 
  84.    mov  bx, ax 
  85.    shl  ax, 8 
  86.    shl  bx, 6 
  87.    add  ax, bx 
  88.    add  ax, X 
  89.    mov  di, ax 
  90.    mov  ax, $A000 
  91.    mov  es, ax 
  92.    mov  al, Color 
  93.    mov  es:[di], al 
  94.    pop  di
  95.    pop  es
  96. end;
  97.